package com.szqhyxj.youxiangju.biz.merchantHome.shop.order.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;

import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.biz.merchantHome.bean.FacilityList;
import com.szqhyxj.youxiangju.biz.merchantHome.shop.adapter.FacilityListAdapter;
import com.szqhyxj.youxiangju.sys.components.view.popview.BaseDialog;

import java.util.ArrayList;
import java.util.List;

/**
 * XiaoPanYu
 * on 2018/10/27
 */
public class FacilityListPopView extends BaseDialog {

    private ListView list;
    private OnClickListener listener;
    private List<FacilityList> stockPOList = new ArrayList<>();
    ImageView close;
    public FacilityListPopView(Context context, List<FacilityList> facilityList) {
        super(context);
        stockPOList.addAll(facilityList);
        FacilityListAdapter adapter = new FacilityListAdapter(context, stockPOList);
        list.setAdapter(adapter);
    }


    @Override
    protected View initDialogView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.popview_facility_list, null);
        list = view.findViewById(R.id.list);
        close = view.findViewById(R.id.close);
        close.setOnClickListener(this);
        close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        return view;
    }


    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.btn_cancel:
                if(listener!=null){
                    listener.onCancel(v);
                }
                break;

            case R.id.btn_confirm:
                if (listener != null) {
                    listener.onClickConfirm(v);
                }
                break;

        }
    }

    public interface OnClickListener {
        void onClickConfirm(View v);
        void close(View v);
        void onCancel(View v);
    }


    public void setOnClickListener(OnClickListener listener) {
        this.listener = listener;
    }
}



